<template>
  <div>
    <basic-container>
      <div class="banner-text">
         <div class="lettertop">
           <el-row>
          <el-col :span="8">
             <div class="letterSX">
               <span>客户姓名</span>
                <el-input
                placeholder="请输入客户姓名"
                v-model.trim="name">
                </el-input>
             </div>
          </el-col>
          <el-col :span="8"><div class="letterSX">
               <span>进件单号</span>
                <el-input
                placeholder="请输入进件单号"
                v-model.trim="id">
                </el-input>
             </div></el-col>
          <el-col :span="8"><div class="letterSX">
               <span>手机号</span>
                <el-input
                placeholder="请输入手机号"
                v-model.trim="phone">
                </el-input>
             </div></el-col>
        </el-row>
         </div>
        <div class="lettertop"><el-row>
          <el-col :span="8"><div class="letterSX"></div></el-col>
          <el-col :span="8"><div class="letterSX"><el-button
                class="filter-item"
                type="primary"
                size="medium"
                icon="el-icon-search"
                @click="handleCreate()">查询
              </el-button>
              <el-button
                class="filter-item"
                type="primary"
                size="medium"
                icon="el-icon-delete"
                @click="handleCreateerr()">重置
              </el-button></div></el-col>
          <el-col :span="8"><div class="letterSX"></div></el-col>
          </el-row></div>
          <div>
            <el-table
              :data="tableData"
              
              border
              style="width: 100%">
             
              <el-table-column
                prop="personName"
                label="客户姓名"
                width="180">
              </el-table-column>
              <el-table-column
                prop="statusName"
                label="进件状态">
              </el-table-column>
              <el-table-column
                prop="cellPhoneNo"
                label="手机号">
              </el-table-column>
              <el-table-column
                prop="assetOrderNo"
                label="进件单号">
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="创建时间">
              </el-table-column>
               <el-table-column
                label="操作"
                width="180">
                <template slot-scope="scope">
                    <el-button @click="handleClick(scope,'BL')" type="text" size="small">办理</el-button>
                    <el-button @click="handleClick(scope,'CK')" type="text" size="small">查看</el-button>
                    
                  </template>
              </el-table-column>
            </el-table>
                <el-pagination
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
              :current-page="pageNum"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="100"
              layout="total, sizes, prev, pager, next, jumper"
              :total='total'>
            </el-pagination>
          </div>
      </div>
       <div class="maskMenu" v-if="showPullMenu" @click="handerror()">

    </div>
    <div class="pull_menu" v-if="showPullMenu">
      <div class="menu_box_top border-bottom">
        <span></span>
          <em @click="handerror()"><img src="/img/index/close.png" alt=""></em>
      </div>
        <iframe :src="srcurl" frameborder="0"></iframe>

         <!-- <el-button @click="handsuccess()" type="text" size="medium">确认</el-button>
         <el-button @click="handerror()" type="text" size="small">取消</el-button> -->
         <div class="iframebtn" v-if="status=='BL'">
           <el-button
                class="filter-item"
                type="primary"
                size="medium"
                icon="el-icon-check"
                @click="handsuccess()">提交
              </el-button>
          <el-button
                size="medium"
                icon="el-icon-close"
                @click="handerror()">取消
              </el-button>
         </div>
            
    </div>
    </basic-container>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
// import { try } from 'q';
 import {getSupplementList,getCloudViewUrl,submitSupplement} from '@/api/cpls/cpls'

export default {
  name: 'Letterguarantee',
  data() {
    return {
      showPullMenu:false,
      activeNames: ['1', '2', '3', '4'],
      DATA: [],
      text: '',
      actor: '',
      count: 0,
      isText: false,
      name:"",
      id:"",
      statusBC:"",
      phone:"",
      tableData: [],
      srcurl:"",
       pageNum:1,
      pageSize:10,
      total:0,
      assetOrderNo:"",
      status:""
    }
  },
  computed: {
    ...mapGetters(['website'])
  },
  created(){
         this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
  },
  methods: {
    handsuccess(){
       this.$confirm('是否确认提交?', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(()=>submitSupplement({ 
            "assetOrderNo": this.assetOrderNo, //scope.row.assetOrderNo
            }).then(response => {
              if(response.data.code=='0'){
                  this.$message.success("提交成功");
                  this.showPullMenu=false;
                 this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
              }
          })
        ).catch(function () {
        })
     
    },
   handleClick(scope,status){
    // this.srcurl=scope.assetOrderNo
      //console.log(scope.row.assetOrderNo)
      this.assetOrderNo= scope.row.assetOrderNo
      this.status=status
      if(status=='BL'){
           getCloudViewUrl({ 
            "struct": scope.row.assetOrderNo, //scope.row.assetOrderNo
            "viewId":'materialSupplement'
            }).then(response => {
          
              this.srcurl=response.data.data
          })
      }else{
         getCloudViewUrl({ 
          "struct": scope.row.assetOrderNo, //scope.row.assetOrderNo
          "viewId":'allView'
          }).then(response => {
         
            this.srcurl=response.data.data
        })
      }
     
       
        
     this.showPullMenu=true
     this.statusBC=status
     
   },
   handerror(){
    this.srcurl=''
     this.showPullMenu=false
     this.statusBC=""
   },
   handleCreate(){
     this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
   },
   letterguaranList(personName,assetOrderNo,cellPhoneNo,pageNum,pageSize){
    
       getSupplementList({ 
          personName: personName, 
          assetOrderNo: assetOrderNo, 
          cellPhoneNo:cellPhoneNo,
          "countSql":true,
          "pageNum":pageNum,
          "pageSize":pageSize
          }).then(response => {
            console.log(response)
          this.tableData = response.data.data.list
          this.total=response.data.data.total
        })
   },
    handleSizeChange(val) {
        this.pageSize=val
              this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
      },
      handleCurrentChange(val) {
        this.pageNum=val
             this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
      },
   handleCreateerr(){
     this.name='';
     this.phone='';
     this.id='';
     this.letterguaranList(this.name,this.id,this.phone,this.pageNum,this.pageSize)
   },
   lettersuccbtn(){
     if(this.statusBC=='BL'){
       
     }else{
       this.showPullMenu=false
     }
   },
   letterorbtn(){
     this.showPullMenu=false
   }
  }
}
</script>

<style scoped="scoped" lang="scss">
  .wel-contailer {
    position: relative;
  }

  .banner-text {
    position: relative;
    padding: 0 20px;
    font-size: 20px;
    text-align: center;
    color: #333;
  }
  .lettertop{
    margin-bottom: 20px;
  }
  .letterbottom{
    text-align: center;
  }
  .el-button--small{
    font-size: 14px;
  }
  td,tr{
    div{
      text-align: center;
    }
  }
  .letterdowimg{
      span{
         width: 120px;
         border-radius: 10px;
         border:1px solid #ccc;
         display: inline-block;
         height: 90px;
      }
  }
  .maskMenu {
  position: fixed;
  width: 100%;
  height: 100%;
  z-index: 999;
  background: rgba(0, 0, 0, 1);
  opacity: 0.4;
  top: 64px;
  left: 0;
}
  .pull_menu{
          width: 80%;
    height: 80%;
    top: 15%;
    background: #fff;
    position: fixed;
    z-index: 1000;
    padding:  20px;
    border-radius: 10px;
    iframe{
      width: 100%;
      height: 85%;
    }
    .iframebtn{
      text-align: right;
    }
     .menu_box_top {
    height: 30px;
    line-height: 30px;
    margin-bottom: 0.48rem;
    // border-bottom: 1px solid #ccc;
    span {
      // font-size: 0.32rem;
      font-family: "PingFangSC-Medium";
      color: #363c54;
      float: left;
      margin-left: 0.5rem;
    }
    em {
      width: 22px;
      height: 22px;
      float: right;
      font-size: 20px;
      cursor: pointer;
      // background: url('../')
      // background-image: url("../../../public/img/bg/cloud.jpg");
      // background-size: cover;
      // margin-top: 18px;
      margin-right: 0.5rem;
              img{
              width: 100%;
        }
    }
    }
  }
  .letterSX{
    span{
          display: inline-block;
         line-height: 43px; 
        padding: 0px 10px;
            font-size: 16px;
      }
      .lettersuccbtn{
        display: inline-block;
        background: deepskyblue;
        color: #fff;
        border-radius: 10px;
        padding: 5px 35px;
        margin: 10px;
        cursor: pointer;
            font-size: 16px;
      }
      .letterorbtn{
        display: inline-block;
        border: 1px solid #ccc;
        border-radius: 10px;
        padding: 5px 35px;
        margin: 10px;
        cursor: pointer;
            font-size: 16px;
      }
     .el-input{
       width: 70%;
     }
  }

  // .banner-img {
  //   position: absolute;
  //   top: 0;
  //   left: 0;
  //   width: 100%;
  //   height: 100%;
  //   opacity: 0.8;
  //   display: none;
  // }

  // .actor {
  //   height: 250px;
  //   overflow: hidden;
  //   font-size: 18px;
  //   color: #333;
  // }

  // .actor:after {
  //   content: '';
  //   width: 3px;
  //   height: 25px;
  //   vertical-align: -5px;
  //   margin-left: 5px;
  //   background-color: #333;
  //   display: inline-block;
  //   animation: blink 0.4s infinite alternate;
  // }

  .typeing:after {
    animation: none;
  }

  @keyframes blink {
    to {
      opacity: 0;
    }
  }
</style>
